// 接口地址前缀
const BASE_URL = 'https://teach.dracowyn.com/api/wallpaper';

export function request(config = {}) {
        let {
                url,
                data = {},
                method = "GET",
                header = {}
        } = config;

        url = BASE_URL + url;
        header['Server'] = "true";

        return new Promise((resolve, reject) => {
                console.log(url);
                uni.request({
                        url,
                        data,
                        method,
                        header,
                        // 请求成功
                        success: (res) => {
                                if (res.data.code === 1) {
                                        resolve(res.data);
                                } else {
                                        uni.showModal({
                                                title: "错误提示",
                                                content: res.data.msg,
                                                showCancel: false
                                        })
                                }
                        },
                        fail: (error) => {
                                reject(error)
                        }
                })
        })
}